Make a chain of function decorators (bold, italic, underline etc.)ΒΆ
Make a chain of function decorators
(bold, italic, underline etc.) in python.
def make_bold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def make_italic(fn):
def wrapped():
return "<i>" + fn() + "</i>"
return wrapped
def make_underline(fn):
def wrapped():
return "<u>" + fn() + "</u>"
return wrapped
@make_bold
@make_italic
@make_underline
def hello():
return "hello world"
# test
print(hello()) # <b><i><u>hello world</u></i></b>
Output:
hello world